package Lock;

/**
 * Description: ReentrantLock锁
 * @Date: 2025/9/5
 */
public class ReentrantLock {
    public static void main(String[] args) {
        ReentrantLock lock= new ReentrantLock(  true);
         for (int i = 0; i < 5; i++) {
             lock.lock();
         }

        for(int i=1;i<=3;i++){
            try {

            } finally {
                lock.unlock();
                System.out.println("线程"+Thread.currentThread().getName()+"释放锁");
            }
        }
    }

    private void unlock() {
        System.out.println("释放锁");
    }

    private void lock() {
        System.out.println("获取锁");
    }


    public ReentrantLock(boolean b) {
        super();  //父级super构造器
    }

}
